import requests
import json
from Jv.settings import SRS_API


def delete_stream(live_stream):
    """
    踢流
    """
    srs = SRS_API + 'api/v1/clients'
    try:
        res = requests.post(srs, timeout=3)
    except requests.exceptions.ConnectionError:
        return
    res.text.encode('utf-8')
    html = res.content
    js = json.loads(html)
    for i in js['clients']:
        if live_stream == i['tcUrl']:
            delete_srs = srs + '/' + i['id']
            requests.delete(delete_srs)
    return
